﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace MeetingMinutesManager.Form
{
    public class PopupForm
    {
        private HttpResponse _response;
        private String _navigateURL;
        private String _name;
        private String _width;
        private String _height;
        private String _X;
        private String _Y;

        /// <summary>
        /// Default constructor used to close the form
        /// </summary>
        /// <param name="response"></param>
        public PopupForm(HttpResponse response)
        {
            _response = response;
        }

        /// <summary>
        /// Constructor used to popup a form.
        /// </summary>
        /// <param name="response"></param>
        /// <param name="navigateURL"></param>
        /// <param name="name"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public PopupForm(HttpResponse response, String navigateURL, String name, String width, String height, String X, String Y)
        {
            _response = response;
            _navigateURL = navigateURL;
            _name = name;
            _width = width;
            _height = height;
            _X = X;
            _Y = Y;
        }

        public void Popup()
        {
            _response.Write("<script language=javascript>window.open ('" + _navigateURL + "','" + _name + "','screenX=" + _X + ",screenY=" + _Y + ",location=1,status=1,scrollbars=1,width=" + _width + ",height=" + _height + "'); </script>");
        }

        public void PopupThenClose()
        {
            _response.Write("<script language=javascript>window.open ('" + _navigateURL + "','" + _name + "','screenX=" + _X + ",screenY=" + _Y + ",location=1,status=1,scrollbars=1,width=" + _width + ",height=" + _height + "'); </script>");

            _response.Write("<script> window.close(); </script>");
        }

        public void Close()
        {
            _response.Write("<script> window.close(); </script>");
        }
    }
}
